<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/template.xhtml">

	<ui:define name="content">
		<h:form id="comprarPassagem">

			<p:panel id="oppassagem" display="Ida e Volta">

				<p:selectOneRadio id="idavolta" >
					<f:selectItem itemLabel="Ida" itemValue="false" />
					<f:selectItem itemLabel="Ida e Volta" itemValue="true" />
					<p:ajax event="change" update="oppassagem" />
				</p:selectOneRadio>

				<h:outputText id="partida" value="Data de ida:*" />
				<p:calendar id="dataIda" />

				<h:outputText id="retorno" value="Data de volta:*"
					rendered="#{compraController.via}"></h:outputText>
				<p:calendar id="dataVolta" rendered="#{compraController.via}" />				

				<h:outputText value="Origem: *" />
				<p:selectOneMenu value="#{compraController.origem}"	effect="fade" required="true">
					<f:selectItem itemLabel="Escolha um aeroporto" itemValue="-999" />
					<f:selectItems value="#{vooController.listaAeroportos}" var="aeroporto" itemLabel="#{aeroporto.nome}" itemValue="#{aeroporto.codigo}"></f:selectItems>
				</p:selectOneMenu>

				<h:outputText value="Destino:*" />
				<p:selectOneMenu value="#{compraController.origem}" effect="fade" required="true">
					<f:selectItem itemLabel="Escolha um aeroporto" itemValue="-999" />
					<f:selectItems value="#{vooController.listaAeroportos}"	var="aeroporto" itemLabel="#{aeroporto.nome}" itemValue="#{aeroporto.codigo}" />
				</p:selectOneMenu>
				
				<p:commandButton value="Pesquisar" action="index.xhtml"	update="idaevolta"/>
			</p:panel>

			<p:panel id="idaevolta" display="Passagens Disponíveis">
				<p:dataTable value="#{compraController.voos}" var="voo"
					paginator="true" rows="10">

					<p:column selectionMode="single" style="width:2%" />

					<p:column>

						<h:outputText value="voo.id" />
						<f:facet name="header">
							<h:outputText value="Código do voo" />
						</f:facet>

					</p:column>

					<p:column>

						<h:outputText value="voo.from.nome" />
						<f:facet name="header">
							<h:outputText value="De" />
						</f:facet>

					</p:column>

					<p:column>

						<h:outputText value="voo.to.nome" />
						<f:facet name="header">
							<h:outputText value="Para" />
						</f:facet>

					</p:column>

					<p:column>

						<h:outputText value="voo.duracao" />
						<f:facet name="header">
							<h:outputText value="Tempo de voo" />
						</f:facet>

					</p:column>
				</p:dataTable>


				<p:dataTable value="#{compraController.voos}" var="voo"
					paginator="true" rows="10">

					<p:column selectionMode="single" style="rwidth:2%" />

					<p:column>

						<h:outputText value="voo.id" />
						<f:facet name="header">
							<h:outputText value="Código do voo" />
						</f:facet>

					</p:column>

					<p:column>

						<h:outputText value="voo.to.nome" />
						<f:facet name="header">
							<h:outputText value="De" />
						</f:facet>

					</p:column>

					<p:column>

						<h:outputText value="voo.from.nome" />
						<f:facet name="header">
							<h:outputText value="Para" />
						</f:facet>

					</p:column>

					<p:column>

						<h:outputText value="voo.duracao" />
						<f:facet name="header">
							<h:outputText value="Tempo de voo" />
						</f:facet>

					</p:column>
				</p:dataTable>

				<p:commandButton value="Comprar" action="index.xhtml" />

			</p:panel>


		</h:form>

	</ui:define>
</ui:composition>


</html>